<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>picker</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<link href="css/picker.css" rel="stylesheet" />
		<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js" ></script>
		<script type="text/javascript" src="picker.js"></script>
	</head>
	<body>
		<script>
		//第一种数据格式，单列 type=1
			var one = [
				{
					name:'今天',
					value:'tody'
				},
				{
					name:'明天',
					value:'tomorrow'
				}
			];
			//第2种数据格式，二级联动的 type=2
			var two = [
				{
					name:'今天',
					value:'today',
					child:[
						{name:'8:00',value:'8'},
						{name:'9:00',value:'9'},
						{name:'8:00',value:'8'},
						{name:'9:00',value:'9'}
					]
				},
				{
					name:'明天',
					value:'tomorrow',
					child:[
						{name:'10:00',value:'10'},
						{name:'11:00',value:'11'},
						{name:'10:00',value:'10'},
						{name:'11:00',value:'11'}
					]
				},
				{
					name:'明天',
					value:'tomorrow',
					child:[
						{name:'8:00',value:'8'},
						{name:'9:00',value:'9'}
					]
				}
			];
			//第三种数据格式，2级，但不联动 type=3
			var three = {
				parent:[
					{
						name:'今天',
						value:'tody'
					},
					{
						name:'明天',
						value:'tomorrow'
					},
					{
						name:'今天',
						value:'tody'
					},
					{
						name:'明天',
						value:'tomorrow'
					}
				],
				child:[
					{
						name:'今天',
						value:'tody'
					},
					{
						name:'明天',
						value:'tomorrow'
					},
					{
						name:'今天',
						value:'tody'
					},
					{
						name:'明天',
						value:'tomorrow'
					}
				]
			};
			//第四种数据格式，3级，联动 type=4
			var four = [ 
				{
					name:'1',
					value:'1',
					child:[
						{
							name:'11',
							value:'11',
							child:[
								{name:'111',value:'111'},
								{name:'112',value:'112'},
								{name:'113',value:'113'},
							]
						},
						{
							name:'12',
							value:'12',
							child:[
								{name:'121',value:'121'},
								{name:'122',value:'122'},
								{name:'123',value:'123'},
							]
						},
						{
							name:'13',
							value:'13',
							child:[
								{name:'131',value:'131'},
								{name:'132',value:'132'},
								{name:'133',value:'133'},
							]
						},
					]
				},
				{
					name:'2',
					value:'2',
					child:[
						{
							name:'21',
							value:'21',
							child:[
								{name:'211',value:'211'},
								{name:'221',value:'221'},
								{name:'231',value:'231'},
							]
						},
						{
							name:'22',
							value:'22',
							child:[
								{name:'221',value:'221'},
								{name:'222',value:'222'},
								{name:'223',value:'223'},
							]
						},
						{
							name:'23',
							value:'23',
							child:[
								{name:'231',value:'231'},
								{name:'232',value:'232'},
								{name:'233',value:'233'},
							]
						},
					]
				},
				{
					name:'3',
					value:'3',
					child:[
						{
							name:'31',
							value:'31',
							child:[
								{name:'311',value:'311'},
								{name:'312',value:'312'},
								{name:'313',value:'313'},
							]
						},
						{
							name:'32',
							value:'32',
							child:[
								{name:'321',value:'321'},
								{name:'322',value:'322'},
								{name:'323',value:'323'},
							]
						},
						{
							name:'33',
							value:'33',
							child:[
								{name:'331',value:'331'},
								{name:'332',value:'332'},
								{name:'333',value:'333'},
							]
						},
					]
				}
			];
//			
//			var p = new lcPicker(four,{
//				target:'date-picker',//选择器id，此节点可以存在也可以不存在
//				type:4,
//				title:'测试数据',
//				name:'name',//配置节点的节点name 默认是name
//				value:'value',//配置节点的节点value，默认是value
//				child:'child',//配置节点的子节点,默认是child
//				parent:'parent',//针对不联动的
//				okEvent:function(data){
//					console.log(data);
//				},
//				cancelEvent:function(){
//					
//				}
//			});
			$.post('http://api.xiyiapp.com:8088/api/wx/serviceCitys.json',function(data){
//				console.log(data);
				var p = new lcPicker(data.data.citysVO,{
					target:'date-picker',//选择器id，此节点可以存在也可以不存在
					type:4,
					title:'测试数据',
					name:'areaName',
					value:'no',
					child:'childs',
					okEvent:function(data){
						console.log(data);
					},
					cancelEvent:function(){
						
					}
				});
//				p.addGranData([0,0,4]);
				p.setItem(['350000','350100','350111']);
			});
//			setTimeout(function(){
//				p.setPCurItem(2); //设置父节点选中项
//				p.setCCurItem([2,0]); //设置子节点选中项
//				console.log('2000');
//			},2000);
		</script>
	</body>
</html>
